/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2022-04-16
 * Time: 12:53
 */

//Scanner scan = new Scanner(System.in);

//判断1~n 中有多少个m（m在0~9之间）
//比如1~100 有多少个9
import java.util.Scanner;

public class TestNode3 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();//100
        int m = scan.nextInt();//9
        int count = 0;

        for (int i = 1; i < n; i++) {

            if(i / 10 == m) { //判断十位是不是m
                count++;
            }
            if(i % 10 == m) { //判断个位是不是m
                count++;
            }
        }

        System.out.println(count);

    }
}
